package main

import (
	"encoding/json"
	"fmt"
)

type Student struct {
	ID     int    `json:"id"`
	Gender string `json:"gender"`
	//name   string //私有属性不能被json包访问
	Name string `json:"name"`
	Sno  string `json:"sno"`
}

func main() {
	var s1 = Student{
		ID:     27,
		Gender: "男",
		Name:   "李四",
		Sno:    "9527",
	}

	fmt.Printf("%#v\n", s1) //main.Student{ID:27, Gender:"男", Name:"李四", Sno:"9527"}

	str, _ := json.Marshal(s1)
	fmt.Println(string(str)) //{"id":27,"gender":"男","name":"李四","sno":"9527"}

}
